package com.ftg.learn.chapter12.tow;

import com.ftg.learn.chapter12.Student;

import java.util.Arrays;

/**
 * @author kangjx
 * @createTime 2022/8/1
 */
public class Stu1Table {

    private Stu1[] stus;
    private int index = 0;

    public Stu1Table(){
        this.stus = new Stu1[10];
    }

    public void add(Stu1 s){
        //扩容
        this.stus[index++] = s;
    }

    public Stu1[] getAllStudent(){
        return Arrays.copyOf(stus,index);
    }

    public static void main(String[] args) {
        Cla1Table classes = new Cla1Table();
        classes.add(new Cla1("1001","研发一部"));
        classes.add(new Cla1("1002","研发二部"));
        classes.add(new Cla1("1003","研发三部"));
        classes.add(new Cla1("1004","研发四部"));


        Stu1Table stu = new Stu1Table();

        Stu1 s = new Stu1();
        s.setSno("10001");
        s.setSname("张狗蛋");
        s.setCno("1001");
        stu.add(s);

        Stu1 s1 = new Stu1();
        s1.setSno("10002");
        s1.setSname("李春花");
        s1.setCno("1001");

        stu.add(s1);

        Stu1[] stues = stu.getAllStudent();
        for (int i = 0; i < stues.length; i++) {
            System.out.println(stues[i].getSname()+"姓名");
            System.out.println(stues[i].getCno()+"班级编号");
        }
    }

}
